package com.listeningframework.boot.autoconfigure.template.sitemesh;

import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * SiteMesh Filter Mapping
 *  
 * @author lixining
 * @version $Id: SiteMeshDecoratorMappingController.java, v 0.1 2015年4月17日 下午5:17:50 lixining Exp $
 */
@Controller
@ConditionalOnClass(ConfigurableSiteMeshFilter.class)
@RequestMapping(SitemeshMappingController.PREFIX_MAPPING)
public class SitemeshMappingController {

    /**
     * 跳转基础路径
     */
    public static final String PREFIX_MAPPING   = "/sitemesh";

    /**
     * 资源路径
     */
    public static final String RESOURCE_RPREFIX = "common/layouts/";

    /**
     * Common Decorator Mapping
     * 
     * @param mapping 映射
     * @return String
     */
    @RequestMapping("/{mapping}")
    public String doFilter(@PathVariable("mapping") String mapping) {
        return RESOURCE_RPREFIX + mapping;
    }
}
